<template>
    <div class="stepBox">
        <div class="box_desc">
            <div class="num_box hover" @click="stepClick(item)" v-for="item in stepListnew">
                <div class="iconBox" :class="stepNum == item.code ? 'active' :''">
                    {{ item.code }}
                </div>
                <div class="nameBox" :class="state.num == item.code ? 'active' :''">{{item.name}}</div>
                <div v-if="item.code!=3" :style="{width:item.width}" class="lineBox">
                </div>
            </div>
        </div>
    </div>
</template>
<script setup>
    import {
        computed,
        reactive,
        watchEffect
    } from 'vue';
    import axios from "@/utils/request"
    import {
        searchchannelNoList
    } from '@/api/config'
    import useUserStore from "@/store/modules/user";
    const {
        proxy
    } = getCurrentInstance();
    const userStore = useUserStore();
    const props = defineProps({
        stepNum: {
            default: () => 1,
            type: Number,
        },
        stepList: {
            type: Array,
            default: () => {
                return [{
                    name: '设置组合报警名称',
                    code: 1,

                }, {
                    name: '选择因子',
                    code: 2
                }, {
                    name: '分析条件',
                    code: 3
                }]
            }
        }
    })
    // 重点
    const state = reactive({
        num: 1
    })
    const stepListnew = computed(() => {
        let w = '100%';
        props.stepList.forEach(item => {
            item.width = `calc(${w} - ${item.name.length*16+72}px)`
        })
        return props.stepList
    })

    function stepClick(item) {
        state.num = item.code
    }
</script>
<style lang="scss" scoped>
    .box_desc {
        display: flex;
        justify-content: center;
        height: 50px;
        align-items: center;
    }

    :deep(.el-steps--horizontal) {
        display: flex;
    }

    :deep(.el-step.is-horizontal .el-step__line) {
        top: 18px;
        height: 1px;
    }

    .stepBox {
        text-align: center;
    }

    .iconBox {
        width: 36px;
        height: 36px;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: rgba(240, 240, 240, 1);
        border-radius: 50%;
        color: rgba(62, 70, 79, 0.8);
        font-size: 16px;

        &.active {
            background-color: rgba(42, 132, 235, 1);
            color: #fff;
        }

    }

    .num_box {
        display: flex;
        align-items: center;
        width: 30%;

        &:last-child {
            width: auto;
        }
    }

    .nameBox {
        margin: 0 10px;
        color: rgba(62, 70, 79, 0.8);

        &.active {
            color: rgba(62, 70, 79, 1);
        }
    }

    .lineBox {
        height: 1px;
        background-color: rgba(240, 240, 240, 1);
    }
</style>